<template>
  <div>
    <!-- 1.目录位置 -->
    <div class="nav">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>个人信息</el-breadcrumb-item>
      </el-breadcrumb>
    </div>

    <el-card class="size">
      <el-descriptions
        class="margin-top"
        title="简介"
        :column="1"
        border
        size="medium "
      >
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-picture"></i>
            头像
          </template>
          <img :src="src" />
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-user"></i>
            账户名
          </template>
          {{ userinfo.user }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-odometer"></i>
            年龄
          </template>
          {{ age }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-male"></i>
            <i class="el-icon-female"></i>
            性别
          </template>
          <el-tag size="small">{{ sex }}</el-tag>
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-message"></i>
            邮箱Email
          </template>
          {{ email }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-mobile-phone"></i>
            手机号码
          </template>
          {{ mobilePhoneNumber }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-location-outline"></i>
            地区
          </template>
          {{ area }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-office-building"></i>
            职业
          </template>
          {{ work }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-basketball"></i>
            兴趣爱好
          </template>
          {{ hobby }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-date"></i>
            注册日期
          </template>
          {{ createDate }}
        </el-descriptions-item>
      </el-descriptions>
    </el-card>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  data() {
    return {
      age: '',
      email: "",
      mobilePhoneNumber: "",
      area: "",
      createDate: "",
      sex: "",
      work: "",
      hobby: "",
      src:"",
    };
  },
  computed: {
    ...mapState("loginModules",['userinfo'])
  },
  mounted() {
    this.getUserInfoData()
  },
  methods: {
    getUserInfoData(){
      this.$api.getUserInfo({
        username:this.userinfo.user
      }).then(res=>{
        console.log(res.data.data[0]);
        this.email = res.data.data[0].email
        this.age = res.data.data[0].age
        this.createDate = res.data.data[0].date
        this.hobby = res.data.data[0].hobby
        this.area = res.data.data[0].area
        this.sex = res.data.data[0].sex
        this.mobilePhoneNumber = res.data.data[0].telphone
        this.work = res.data.data[0].job
        this.src = require(`${res.data.data[0].src}`)
        console.log(this.src);
      })
    }
  },
};
</script>

<style lang="less" scoped>
.nav{
  margin-top: 10px;
  margin-bottom: 15px;
  margin-left: 10px;
}
img {
  width: 80px;
  height: 80px;
}
.size {
  background-color: rgba(255, 255, 255, 0.3);
  width: 1330px;
  height: 650px;
}
</style>